Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ItemCard UI Helper #5454

Merged
merged 9 commits into from
Dec 25, 2022
Merged

Conversation

Web-eWorks
Copy link
Member

Another PR split from the Scout Mission branch. Don't expect a long shelf life before merge.

This PR improves the "equipment item card" UI paradigm used in the ship equipment display widget and breaks it out into its own generic UI.ItemCard class for any module to use. It also adds a helper to draw a "blank" item card (e.g. an empty item slot), and improves the ability of surrounding elements to layout correctly relative to the space it takes up.

This PR also includes a slightly opinionated change that unifies all "basic tooltips" set with ui.setTooltip() to use a consistent font size regardless of the font size active when the tooltip is set. You can override this by using the custom- tooltip facilities as needed, but this change fixes several very glaring paper-cuts with a tooltip changing font size depending on which part of the element you're hovering over.

This PR also adds a number of basic utilities to the Lua execution environment:

  • Provide a shortcut for string.interp and add implicit positional argument support.
    "test {} {abc}" % { "123", abc="def" } = "test 123 def"
  • Add math.lerp and math.invlerp functions for any objects supporting basic math operations (add, sub, mul, div).
  • Add a "shallow" table.copy helper

- Table.copy makes a shallow copy of the passed table
- Add extra documentation to generic functions in the utils module
- String.interp now supports positional parameters
- string __mod operator for more ergonomic use
- Math.lerp interpolates any "linear object" (addition, subtraction, multiplication operators) between two values
- Math.invlerp calculates an "interpolation factor" (usually, a number between 0 and 1) for the given min/max/current values, the equivalent of taking the inverse of Math.lerp.
- Basic text tooltips are now displayed with a common and consistent font size
- You can still use ui.customTooltip() to use custom styling/font size/tooltip contents
- Expose explicit group handling with beginGroup() / endGroup(); reduces function call nesting in complex layouts
Split equipment section drawing into multiple functions to facilitate adding ship hardpoint display.
- Separates out display functionality from the Ship Equipment widget so other modules can display in a similar style.
- Individual card types can customize display handling and define how many stats fields they want to show
- Add helpers to draw an empty ItemCard
@Web-eWorks Web-eWorks merged commit 6bf3f03 into pioneerspacesim:master Dec 25, 2022
@Web-eWorks Web-eWorks deleted the item-card branch December 26, 2022 01:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant